#include "cobra11syndicate.hlsli"
#include "standard.hlsli"

struct PS_Input_C11Auto 
{
float4 v7 : SV_Position /* dcl vPos.xy */ ;
float3 o3 : texcoord /* dcl_texcoord o3.xyz */ ;
float3 VertexColor : texcoord1 /* dcl_texcoord1 v0.xyz */ ;
float4 diffuseColor : texcoord2 /* dcl_texcoord2 v1.xy */ ;
float4 o6 : texcoord4 /* dcl_texcoord4 o6 */ ;
float4 o7 : texcoord6 /* dcl_texcoord6 o7 */ ;
float4 normal : texcoord7 /* dcl_texcoord7 v2 */ ;
float4 o1 : color /* dcl_color o1 */ ;
float4 o2 : color1 /* dcl_color1 o2 */ ;
float distanceToCamera : FOG /* dcl_fog v3.x */ ;
};



float4 ps_main(PS_Input_C11Auto psInAuto) : SV_Target
{

float4 c0 = float4(0.790000021, 0.709999979, 0.209999993, 0.230000004); // def c0, 0.790000021, 0.709999979, 0.209999993, 0.230000004
float4 c1 = float4(1.01800001, 1.01900005, 5, 11); // def c1, 1.01800001, 1.01900005, 5, 11
float4 c2 = float4(10.79, 10.71, 0.200000003, -0.5); // def c2, 10.79, 10.71, 0.200000003, -0.5
float4 c3 = float4(0.400000006, 0.200000003, -1, 0); // def c3, 0.400000006, 0.200000003, -1, 0
float4 c4 = float4(1, 2, 3, 4); // def c4, 1, 2, 3, 4
float4 c5 = float4(10, 3, -2, 5770.78027); // def c5, 10, 3, -2, 5770.78027
float4 c6 = float4(1, 0, -1, -2); // def c6, 1, 0, -1, -2
float4 c7 = float4(0.25, 0.75, 20, 300); // def c7, 0.25, 0.75, 20, 300
float4 c8 = float4(9.99999975e-005, -0.5, -0.0149999997, 0); // def c8, 9.99999975e-005, -0.5, -0.0149999997, 0
float4 c9 = float4(0.899999976, 0.200000003, 0.100000001, 0.150000006); // def c9, 0.899999976, 0.200000003, 0.100000001, 0.150000006
float4 c10 = float4(0.800000012, 1, 0, 0); // def c10, 0.800000012, 1, 0, 0


float4 oC0 = (float4)0;
float4 r0 = (float4)0;
float4 r1 = (float4)0;
float4 r2 = (float4)0;
float4 r3 = (float4)0;
float4 r4 = (float4)0;
float4 r5 = (float4)0;



r0.x = dot(psInAuto.VertexColor.xyz, psInAuto.VertexColor.xyz);//dp3 r0.x, v0, v0
r0.x = rsqrt(r0.x);//rsq r0.x, r0.x
if (DitherFlag)
{ //if b4
r0.y = 1.0f / r0.x;//rcp r0.y, r0.x
r0.zw = psInAuto.v7.xy * DitherTexParams.xy +  DitherTexParams.zw;//mad r0.zw, vPos.xyxy, c20.xyxy, c20
r1.xyzw = TexDither.Sample(DitherTex, r0.zw);//texld r1, r0.zwzw, s15
r0.z = r1.w * DitherClipParams.y;//mul r0.z, r1.w, c21.y
r0.y = r0.y * DitherClipParams.x +  r0.z;//mad r0.y, r0.y, c21.x, r0.z
r1.xyzw = r0.y + DitherClipParams.z;//add r1, r0.y, c21.z
clip(r1.xyzw);//texkill r1
} //endif
r1.xyzw = WaterAnim.xyzw;//mov r1, c23
r0.yz = psInAuto.diffuseColor.xy * c0.xy +  r1.xy;//mad r0.yz, v1.xxyw, c0.xxyw, r1.xxyw
r2.xyzw = Tex1.Sample(DiffuseTex1, r0.yz);//texld r2, r0.yzzw, s0
r0.yz = WaterAnim.zw + psInAuto.diffuseColor.xy;//add r0.yz, c23.xzww, v1.xxyw
r3.xyzw = Tex1.Sample(DiffuseTex1, r0.yz);//texld r3, r0.yzzw, s0
//return r3;
r2.xyzw = r2.zwxy + r3.zwxy;//add r2, r2.zwxy, r3.zwxy
r3.xyzw = r1.xyxy * c1.xyzz;//mul r3, r1.xyxy, c1.xyzz
r0.yz = psInAuto.diffuseColor.xy * c0.zw +  r3.xy;//mad r0.yz, v1.xxyw, c0.xzww, r3.xxyw
r4.xyzw = Tex1.Sample(DiffuseTex1, r0.yz);//texld r4, r0.yzzw, s0
r2.xyzw = r2.xyzw + r4.zwxy;//add r2, r2, r4.zwxy
r0.yz = psInAuto.diffuseColor.xy * c2.xy +  r3.zw;//mad r0.yz, v1.xxyw, c2.xxyw, r3.xzww
r3.xyzw = Tex1.Sample(DiffuseTex1, r0.yz);//texld r3, r0.yzzw, s0
r2.xyzw = r2.xyzw + r3.zwxy;//add r2, r2, r3.zwxy
r0.yz = c1.w * psInAuto.diffuseColor.xy;//mul r0.yz, c1.w, v1.xxyw
r0.yz = r1.zw * c1.z +  r0.yz;//mad r0.yz, r1.xzww, c1.z, r0
r1.xyzw = Tex1.Sample(DiffuseTex1, r0.yz);//texld r1, r0.yzzw, s0
r1.xyzw = r1.zwxy + r2.xyzw;//add r1, r1.zwxy, r2
//return r1;
r0.yzw = r1.zxw * c3.xyx +  c3.zwz;//mad r0.yzw, r1.xzxw, c3.xxyx, c3.xzwz
r2.xyz = normalize(r0.yzw);//nrm r2.xyz, r0.yzww
r0.xyz = r0.x * psInAuto.VertexColor.xyz;//mul r0.xyz, r0.x, v0
r0.w = dot(r2.xyz, r0.xyz);//dp3 r0.w, r2, r0
r1.x = r0.w + r0.w;//add r1.x, r0.w, r0.w
r0.xyz = r1.x * r2.xyz +  -r0.xyz;//mad r0.xyz, r1.x, r2, -r0
if (ShadowsFlag)
{ //if b1
r1.x = r1.y * c2.z +  c2.w;//mad r1.x, r1.y, c2.z, c2.w
r1.x = r1.x * c5.x +  psInAuto.normal.y;//mad r1.x, r1.x, c5.x, v2.y
r1.y = r1.x + c5.y;//add r1.y, r1.x, c5.y
r1.w = psInAuto.normal.z * SelCascade.x +  SelCascade.y;//mad r1.w, v2.z, c35.x, c35.y
r1.w = log(r1.w);//log r1.w, r1.w
r1.w = r1.w * SelCascade.z +  SelCascade.w;//mad r1.w, r1.w, c35.z, c35.w
r2.x = max(r1.w, c3.w);//max r2.x, r1.w, c3.w
r1.w = min(r2.x, c5.y);//min r1.w, r2.x, c5.y
r2.x = frac(r1.w);//frc r2.x, r1.w
r2.x = r1.w + -r2.x;//add r2.x, r1.w, -r2.x
r3.xyzw = r1.w + c6.xyzw;//add r3, r1.w, c6
r4.xyzw = -r1.w + c4.xyzw;//add r4, -r1.w, c4
r5.xyzw = min(r3.xyzw, r4.xyzw);//min r5, r3, r4
r3.xyzw = max(r5.xyzw, c3.w);//max r3, r5, c3.w
r1.w = dot(r3.xyzw, ShadowNormalOffset.xyzw);// dp4 r1.w, r3, c22
r3.z = r1.w * ShadowNormalMat._m12;//mul r3.z, r1.w, c19.y
r3.x = r1.w * ShadowNormalMat._m10;//mul r3.x, r1.w, c17.y
r3.y = r1.w * ShadowNormalMat._m11;//mul r3.y, r1.w, c18.y
r1.xz = psInAuto.normal.xz;//mov r1.xz, v2
r1.xyz = r1.xyz + r3.xyz;//add r1.xyz, r1, r3
r2.y = r2.x + c5.z;//add r2.y, r2.x, c5.z
r1.w = -c3.z;//mov r1.w, -c3.z
r3.xyzw = ShadowMats[0]._m02_m12_m22_m32;//mov r3, c38
r3.xyzw = float4(-abs(r2.x) < 0 ? r3.x : ShadowMats[1]._m02,
-abs(r2.x) < 0 ? r3.y : ShadowMats[1]._m12,
-abs(r2.x) < 0 ? r3.z : ShadowMats[1]._m22,
-abs(r2.x) < 0 ? r3.w : ShadowMats[1]._m32);
//cmp r3, -r2_abs.x, r3, c41
r4.xyzw = ShadowMats[2]._m02_m12_m22_m32;//mov r4, c44
r4.xyzw = float4(-r2.y < 0 ? r4.x : ShadowMats[3]._m02,
-r2.y < 0 ? r4.y : ShadowMats[3]._m12,
-r2.y < 0 ? r4.z : ShadowMats[3]._m22,
-r2.y < 0 ? r4.w : ShadowMats[3]._m32);
//cmp r4, -r2.y, r4, c47
r3.xyzw = float4(r2.y < 0 ? r4.x : r3.x,
r2.y < 0 ? r4.y : r3.y,
r2.y < 0 ? r4.z : r3.z,
r2.y < 0 ? r4.w : r3.w);
//cmp r3, r2.y, r4, r3
r3.z = dot(r1.xyzw, r3.xyzw);// dp4 r3.z, r1, r3
r4.xyzw = ShadowMats[0]._m00_m10_m20_m30;//mov r4, c36
r4.xyzw = float4(-abs(r2.x) < 0 ? r4.x : ShadowMats[1]._m00,
-abs(r2.x) < 0 ? r4.y : ShadowMats[1]._m10,
-abs(r2.x) < 0 ? r4.z : ShadowMats[1]._m20,
-abs(r2.x) < 0 ? r4.w : ShadowMats[1]._m30);
//cmp r4, -r2_abs.x, r4, c39
r5.xyzw = ShadowMats[2]._m00_m10_m20_m30;//mov r5, c42
r5.xyzw = float4(-r2.y < 0 ? r5.x : ShadowMats[3]._m00,
-r2.y < 0 ? r5.y : ShadowMats[3]._m10,
-r2.y < 0 ? r5.z : ShadowMats[3]._m20,
-r2.y < 0 ? r5.w : ShadowMats[3]._m30);
//cmp r5, -r2.y, r5, c45
r4.xyzw = float4(r2.y < 0 ? r5.x : r4.x,
r2.y < 0 ? r5.y : r4.y,
r2.y < 0 ? r5.z : r4.z,
r2.y < 0 ? r5.w : r4.w);
//cmp r4, r2.y, r5, r4
r3.x = dot(r1.xyzw, r4.xyzw);// dp4 r3.x, r1, r4
r4.xyzw = ShadowMats[0]._m01_m11_m21_m31;//mov r4, c37
r4.xyzw = float4(-abs(r2.x) < 0 ? r4.x : ShadowMats[1]._m01,
-abs(r2.x) < 0 ? r4.y : ShadowMats[1]._m11,
-abs(r2.x) < 0 ? r4.z : ShadowMats[1]._m21,
-abs(r2.x) < 0 ? r4.w : ShadowMats[1]._m31);
//cmp r4, -r2_abs.x, r4, c40
r5.xyzw = ShadowMats[2]._m01_m11_m21_m31;//mov r5, c43
r5.xyzw = float4(-r2.y < 0 ? r5.x : ShadowMats[3]._m01,
-r2.y < 0 ? r5.y : ShadowMats[3]._m11,
-r2.y < 0 ? r5.z : ShadowMats[3]._m21,
-r2.y < 0 ? r5.w : ShadowMats[3]._m31);
//cmp r5, -r2.y, r5, c46
r2.xyzw = float4(r2.y < 0 ? r5.x : r4.x,
r2.y < 0 ? r5.y : r4.y,
r2.y < 0 ? r5.z : r4.z,
r2.y < 0 ? r5.w : r4.w);
//cmp r2, r2.y, r5, r4
r3.y = dot(r1.xyzw, r2.xyzw);// dp4 r3.y, r1, r2
r3.w = -c3.z;//mov r3.w, -c3.z
r1.xyzw = TexShadowMap.Sample(ShadowMap, r3.xy / r3.w);//texldp r1, r3, s7
}
else
{ //else
r1.x = -c3.z;//mov r1.x, -c3.z
} //endif
r1.y = saturate(dot(r0.xyz, LightVec.xyz));//dp3_sat r1.y, r0, c14
r1.y = r1.y + c3.z;//add r1.y, r1.y, c3.z
r1.y = r1.y * c5.w;//mul r1.y, r1.y, c5.w
r1.y = exp(r1.y);//exp r1.y, r1.y
r1.y = saturate(r1.y * c1.z);//mul_sat r1.y, r1.y, c1.z
r1.y = r1.x * r1.y;//mul r1.y, r1.x, r1.y
r1.y = r1.y * c7.z;//mul r1.y, r1.y, c7.z
r2.xyzw = TexEnvMapTex.Sample(EnvMapTex, r0.xyz);//texld r2, r0, s9
//return r2;
r0.x = r1.x * c7.x +  c7.y;//mad r0.x, r1.x, c7.x, c7.y
r1.xyz = r2.xyz * r0.x +  r1.y;//mad r1.xyz, r2, r0.x, r1.y
r0.w = saturate(r0.w);//mov_sat r0.w, r0.w
r0.y = r0.w * -c4.w;//mul r0.y, r0.w, -c4.w
r0.y = exp(r0.y);//exp r0.y, r0.y
r0.y = r0.y * c9.w +  c9.z;//mad r0.y, r0.y, c9.w, c9.z
r0.yzw = r0.y * r1.xyz;//mul r0.yzw, r0.y, r1.xxyz
r1.w = r0.w;
return r2;
r1.xy = psInAuto.v7.xy * ScreenTex.xy +  ScreenTex.zw;//mad r1.xy, vPos, c24, c24.zwzw
r1.xyzw = TexDepthTex.Sample(DepthTex, r1.xy);//texld r1, r1, s10
//r1 = float4(0.5, 1, 0.5, 1);
r1.y = c7.w + psInAuto.normal.w;//add r1.y, c7.w, v2.w
r1.z = saturate(psInAuto.normal.w * c8.x +  c8.y);//mad_sat r1.z, v2.w, c8.x, c8.y
r2.x = lerp(r1.x, r1.y, r1.z);//lrp r2.x, r1.z, r1.y, r1.x
r1.x = r2.x + -psInAuto.normal.w;//add r1.x, r2.x, -v2.w
r1.y = r1.x * c8.z;//mul r1.y, r1.x, c8.z
r1.y = exp(r1.y);//exp r1.y, r1.y
r1.x = (r1.x < 0 ? r1.y : -c3.z);
//r1.w = 1; return r1;
//cmp r1.x, r1.x, r1.y, -c3.z
oC0.w = 1;// r1.x * -c10.x + c10.y;//mad_pp oC0.w, r1.x, -c10.x, c10.y
r0.yzw = r0.yzw * SunColor.xyz;//mul r0.yzw, r0, c15.xxyz
r1.y = r1.x * c9.x +  c9.y;//mad r1.y, r1.x, c9.x, c9.y
r1.x = -r1.x + -c3.z;//add r1.x, -r1.x, -c3.z
r1.yzw = r1.y * c9.zyw;//mul r1.yzw, r1.y, c9.xzyw
r1.xyz = r1.x * r1.yzw;//mul_pp r1.xyz, r1.x, r1.yzww
r0.xyz = r1.xyz * r0.x +  r0.yzw;//mad_pp r0.xyz, r1, r0.x, r0.yzww
r0.xyz = r0.xyz + -FogColor.xyz;//add r0.xyz, r0, -c29
oC0.xyz = psInAuto.distanceToCamera.x * r0.xyz +  FogColor.xyz;//mad_pp oC0.xyz, v3.x, r0, c29
return oC0;
}


